import * as THREE from "three";

// 解析插槽节点
export function parseSlot({ angle, imgPos, imgSize, box, offsetX = 0.001 }) {
    let obj = new THREE.Object3D()
    obj.rotateX(THREE.MathUtils.degToRad(angle))
    const size = box.getSize(new THREE.Vector3())
    // 换算坐标
    // 图片坐标以左上角为原点，x向右，y向下
    // 三维坐标以最下中心为原点，z向左，y向上
    obj.position.set(
        box.max.x + offsetX, // 偏移贴的面
        box.max.y - (imgPos[1] / imgSize[1]) * size.y,
        box.max.z - (imgPos[0] / imgSize[0]) * size.z,
    )
    return obj
}
